using System.Collections.Generic;

namespace Box;

public class ProcessNodeControlPort {
    public string Name;
    public int SlotID;
    public List<ProcessNodeControlPort> Connects = new List<ProcessNodeControlPort>();
    public ProcessNodeControl Node;

    public ProcessNodeControlPort(string name,int slot_id)
    {
        Name = name;
        SlotID = slot_id;
    }

    public void Connect(ProcessNodeControlPort port) {
        if(Connects.Contains(port)) return;
        Connects.Add(port);
        port.Connects.Add(this);
    }

    public void Disconnect(ProcessNodeControlPort port) {
        if(Connects.Contains(port)) {
            Connects.Remove(port);
            port.Connects.Remove(this);
        }
    }

    public void DisconnectAll() {
        foreach(var port in Connects) {
            port.Connects.Remove(this);
        }
        Connects.Clear();
    }
}